﻿String.prototype.ToObject = function () {
    try {
        if (this != null && this.length > 0)
            return eval('(' + util.replaceAll(this, "\\", "/") + ')');
    }
    catch (ex) { }
    return new Object();
};

var parse = (function () {
    return {
        toInt: function (str) {
            var int = parseInt(str);

            if (isNaN(int))
                int = null;

            return int;
        },

        toDictionary: function (data, key, value) {
            var lst = new Array();

            for (var i = 0; i < data.length; i++) {
                lst.push([data[i][key].toString(), data[i][value]])
            }

            return lst;
        },

        toBoolean: function (string) {
            if ("1" == string || "true" == string || "True" == string || "Checked" == string || "checked" == string || string == true)
                return true;
            else
                return false;
        },

        toString: function (str) {
            if (str != undefined)
                return str;
            else
                return "";
        },

        toUTC: function (val) {
            var dateParts = util.replaceAll(val, "-", "/").split("/");
            return Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2]);
        }
    }
})();